﻿using System;
using System.IO;
using System.Collections.Generic;
using SharpTrainer.Util;
using Zeus.Thunder.Core;

namespace SharpTrainer.Other
{
    class SerializeToMemoryTest : ITestCase
    {
        public void Run()
        {
            // Create a graph of objects to serialize them to the stream 
            var objectGraph = new List<String> { "Jeff", "Kristin", "Aidan", "Grant", "David" };
            Stream stream = SerializeUtil.SerializeToMemory(objectGraph);

            // Reset everything for this demo
            stream.Position = 0;
            objectGraph = null;

            // Deserialize the objects and prove it worked
            objectGraph = (List<String>)SerializeUtil.DeserializeFromMemory(stream);
            foreach (var s in objectGraph) 
                Console.WriteLine(s);
        }
    }
}
